package com.answer.petadoption.mapper;

import com.answer.petadoption.model.entity.Application;
import org.apache.ibatis.annotations.*;

public interface ApplicationMapper {
    @Select("SELECT * FROM application WHERE id = #{id}")
    Application getApplicationById(Long id);

    @Insert("INSERT INTO application (userId, animalId, application_reason, status, review_comments, reviewed_by, applicationTime, reviewTime, createdTime, updatedTime, deletedTime) "
            + "VALUES (#{userId}, #{animalId}, #{applicationReason}, #{status}, #{reviewComments}, #{reviewedBy}, #{applicationTime}, #{reviewTime}, #{createdTime}, #{updatedTime}, #{deletedTime})")
    void insertApplication(Application application);

    @Update("UPDATE application SET userId = #{userId}, animalId = #{animalId}, application_reason = #{applicationReason}, status = #{status}, review_comments = #{reviewComments}, "
            + "reviewed_by = #{reviewedBy}, applicationTime = #{applicationTime}, reviewTime = #{reviewTime}, updatedTime = #{updatedTime}, deletedTime = #{deletedTime} WHERE id = #{id}")
    void updateApplication(Application application);

    @Update("UPDATE application SET deletedTime = NOW() WHERE id = #{id}")
    void deleteApplication(Long id);
}
